/**
 * Copyright 2011 Poltman.Ltd; www.poltman.com. All rights reserved.		
 *
 * This file is part of the dspace-poltman project http://www.poltman.com.
 *
 * This is free software; you can redistribute it and/or modify it under
 * the terms of DuraSpace DSpace license detailed in the LICENSE and NOTICE 
 * files at the root of the source tree and available online at
 * http://www.dspace.org/license/
 * 
 */

package com.poltman.dscentral.db.service.dspace.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.poltman.dscentral.db.entity.dspace.CommunityEntity;
import com.poltman.dscentral.db.exceptions.RepositoryAccessException;
import com.poltman.dscentral.db.exceptions.RepositoryException;
import com.poltman.dscentral.db.repository.dspace.CommunityRepository;
import com.poltman.dscentral.db.service.dspace.CommunityService;




/**
 * 
 * @author z.ciok@poltman.com
 *
 */
@Repository
@Service("communityService")
public class CommunityServiceImpl implements CommunityService {
	
	private static Logger log = Logger.getLogger(CommunityServiceImpl.class);
	
	@Autowired
	private CommunityRepository communityRepository;
	
	@Override
	public List<CommunityEntity> findFirstLevelCommunities() throws RepositoryAccessException, RepositoryException {
		return communityRepository.findFirstLevelCommunities();
	}

	@Override
	public CommunityEntity findByCommunityId(Integer communityId) throws RepositoryAccessException, RepositoryException {
		return communityRepository.findByCommunityId(communityId);
	}
	
	@Override
	public CommunityEntity findByName(String name) throws RepositoryAccessException, RepositoryException {
		return communityRepository.findByName(name);
	}

	@Transactional
	@Override
	public CommunityEntity save(CommunityEntity community) throws RepositoryAccessException, RepositoryException {
		return communityRepository.save(community);
	}
	
	@Transactional
	@Override
	public int setFixedNameAndShortDescriptionFor(String name, String shortDescription, Integer communityId) throws RepositoryAccessException, RepositoryException {
		return communityRepository.setFixedNameAndShortDescriptionFor(name, shortDescription, communityId);
	}
	
	@Transactional
	@Override
	public int setFixedIntroductoryTextFor(String introductoryText, Integer communityId) throws RepositoryAccessException, RepositoryException {
		return communityRepository.setFixedIntroductoryTextFor(introductoryText, communityId);
	}
	
	@Transactional
	@Override
	public int setFixedCopyrightTextFor(String copyrightText, Integer communityId) throws RepositoryAccessException, RepositoryException {
		return communityRepository.setFixedCopyrightTextFor(copyrightText, communityId);
	}
}